﻿using System;

namespace DarcRogue
{
    public class Hud
    {
        string[] messages = new string[4];
        bool halt = false;
        Map map;
        Player player;

        public Hud(Map map)
        {
            this.map = map;
            player = map.Player;
        }

        public bool Halt { get { return halt; } }

        public void AddMessage(string s)
        {
            messages[3] = messages[2];
            messages[2] = messages[1];
            messages[1] = messages[0];
            messages[0] = s;
        }
        public void ClearMessages()
        {
            messages[0] = null;
            messages[1] = null;
            messages[2] = null;
            messages[3] = null;
        }

        public void Draw()
        {
            Console.SetCursorPosition(0, 20);
            Console.Write(LineBreak);
            Console.WriteLine(messages[0] != null ? messages[0] : "");
            Console.WriteLine(messages[1] != null ? messages[1] : "");
            Console.WriteLine(messages[2] != null ? messages[2] : "");
            Console.WriteLine(messages[3] != null ? messages[3] : "");
            for (int i = 0; i < 20; i++)
            {
                Console.SetCursorPosition(50, i);
                Console.Write(" |");
            }
            Console.SetCursorPosition(53, 0);
            Console.Write("Name: " + player.Name);
            Console.SetCursorPosition(0, 0);
        }

        string LineBreak
        {
            get
            {
                string s = "";
                for (int i = 0; i < 80; i++)
                    s += '-';
                return s;
            }
        }
    }
}
